package com.atguigu.springboot.config;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//自定义MyBatis配置规则
@Configuration
@MapperScan(value = {"com.atguigu.springboot.mapper"})
public class MybatisConfig {
    @Bean
    public ConfigurationCustomizer configurationCustomizer() {
        return new ConfigurationCustomizer() {
            @Override
            public void customize(org.apache.ibatis.session.Configuration configuration) {
                //开启驼峰命名
                configuration.setMapUnderscoreToCamelCase(true);
                //别名扫描
                configuration.getTypeAliasRegistry().registerAliases("com.atguigu.springboot.bean");
            }
        } ;
    }
}
